﻿using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using uTILLIty.Rave.Core.StorageAdapter;

namespace uTILLIty.Rave.Core.Strategy
{
  [TestClass]
  public class DefaultConfigurationConstructorStrategyTests : TestBase
  {
    [TestMethod]
    public void BuildFromDirectory()
    {
      var root = new DirectoryInfo(".\\BuildFromDirectory");
      root.Create();

      for (var i = 1; i < 11; i++)
        root.CreateSubdirectory("Dir" + i);

      root.GetDirectories("Dir3")[0].CreateSubdirectory("SubOfDir3");

      var target = new DefaultConfigurationConstructorStrategy();
      var adapter = new NtfsStorageAdapter();
      var result = target.BuildFromDirectory(root.FullName, adapter, true, null, null);
      Assert.IsNotNull(result);
      Assert.AreEqual(1, result.Directories.Length);
      Assert.AreEqual(10, result.Directories[0].SubDirectories.Length);
      Assert.AreEqual(1, result.Directories[0].SubDirectories.Single(d => d.Name == "Dir3").SubDirectories.Length);
    }
  }
}
